﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;

namespace API_lib.Persistence.DAO
{
    /// <summary>
    /// General interface collect the most common methods of a DAO object. Any DAO
    /// object implements this interface may add some more methods to provide
    /// customized access to the underlying database table
    /// </summary>
    /// <typeparam name="BaseMO">Basic Value Object</typeparam>
    public interface DataAccessInterface<BaseMO>
    {
        /// <summary>
        /// Creates a data table for the type.
        /// </summary>
        void createTable();

        /// <summary>
        /// Insert a new row into the database table.
        /// </summary>
        /// <param name="obj">Value object to insert into the database.</param>
	    void insert(BaseMO obj);

        /// <summary>
        /// Insert a new row into the database table, returns its primary key.
        /// </summary>
        /// <param name="obj">Value object to insert into the database.</param>
        /// <returns>The new primary key.</returns>
        int insertReturnPK(BaseMO obj);

        /// <summary>
        /// Update the given row in the database table.
        /// </summary>
        /// <param name="obj">Value object to update in the database.</param>
	    void update(BaseMO obj);

        /// <summary>
        /// Delete the specified row from the database table.
        /// </summary>
        /// <param name="obj">Value object to delete from the database.</param>
	    void delete(BaseMO obj);

        /// <summary>
        /// Return true if the specified record exists in the database.
        /// </summary>
        /// <param name="obj">Value object to check if exists in the database.</param>
        /// <returns>TRUE if the specified record exists in the database.</returns>
	    Boolean isExists(BaseMO obj);

        /// <summary>
        /// Return a Model object with the given id.
        /// </summary>
        /// <returns>An SQLiteDataReader that holds the row with the given id.</returns>
        SQLiteDataReader find(int id);

        /// <summary>
        /// Return a list of all value objects.
        /// </summary>
        /// <returns>SQLiteDataReader containing all rows from the database table</returns>
        SQLiteDataReader getAll();

        /// <summary>
        /// Validates a value object.
        /// </summary>
        /// <param name="obj">value object to be validated</param>
        /// <returns>TRUE if the given value object is valid</returns>
	    Boolean validate(BaseMO obj);
    }
}